package com.example.myapplication.shape;

import android.os.Bundle;
import android.view.View;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.example.myapplication.R;

public class ShapeActivity extends AppCompatActivity implements View.OnClickListener {

    private View shapeView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_shape);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });

        shapeView = findViewById(R.id.shape);
        shapeView.setBackgroundResource(R.drawable.shape_ovil_rose);

        findViewById(R.id.btn_rect).setOnClickListener(this);
        findViewById(R.id.btn_oval).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (R.id.btn_rect == v.getId()) {
            shapeView.setBackgroundResource(R.drawable.shape_rect_gold);
        } else if (R.id.btn_oval == v.getId()) {
            shapeView.setBackgroundResource(R.drawable.shape_ovil_rose);
        }
    }
}